package com.whosly.demo.jmh.simd.benchmark;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * @author fengyang
 * @date 2023/6/26 下午3:56
 * @see <a href="fengyang@stoneatom.com">mailTo: fengyang@stoneatom.com</a>
 */
public class DataPrepare
{
    public static final Random RANDOM = new Random();

    public static final Map<String, byte[]> ARR_MAP = new HashMap<>();

    static {
        ARR_MAP.put("5000", getData(5000));
    }

    private static final byte[] getData(int size) {
        byte[] bytesN = new byte[size];

        RANDOM.nextBytes(bytesN);

        return bytesN;
    }

    protected final byte[] getData(String key) {
        if(ARR_MAP.containsKey(key)) {
            return ARR_MAP.get(key);
        }

        ARR_MAP.put(key, getData(Integer.parseInt(key)));
        return ARR_MAP.get(key);
    }

}
